<?php

/**
 * This is the model class for table "{{group}}".
 *
 * The followings are the available columns in table '{{group}}':
 * @property string $gid
 * @property string $gname
 * @property string $logo
 * @property string $type
 * @property string $tag
 * @property string $creator
 * @property string $theme
 * @property string $config
 * @property string $description
 * @property string $friend_links
 * @property string $url
 * @property string $member_num
 * @property string $post_num
 * @property string $create_time
 * @property string $last_modify_time
 * @property string $status
 */
class GroupData extends BaseData
{
    /**
     * Returns the static model of the specified AR class.
     * @return GroupDao the static model class
     */
    public static function model($className=__CLASS__)
    {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return '{{group}}';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('gname, type', 'required'),
            array('gname, tag', 'length', 'max'=>20),
            array('logo', 'length', 'max'=>32),
            array('type, creator, theme, config, member_num, post_num, create_time, last_modify_time, status', 'length', 'max'=>10),
            array('description', 'length', 'max'=>100),
            array('friend_links, url', 'length', 'max'=>50),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('gid, gname, logo, type, tag, creator, theme, config, description, friend_links, url, member_num, post_num, create_time, last_modify_time, status', 'safe', 'on'=>'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations()
    {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'gid' => 'Gid',
            'gname' => 'Gname',
            'logo' => 'Logo',
            'type' => 'Type',
            'tag' => 'Tag',
            'creator' => 'Creator',
            'theme' => 'Theme',
            'config' => 'Config',
            'description' => 'Description',
            'friend_links' => 'Friend Links',
            'url' => 'Url',
            'member_num' => 'Member Num',
            'post_num' => 'Post Num',
            'create_time' => 'Create Time',
            'last_modify_time' => 'Last Modify Time',
            'status' => 'Status',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria=new CDbCriteria;

        $criteria->compare('gid',$this->gid,true);
        $criteria->compare('gname',$this->gname,true);
        $criteria->compare('logo',$this->logo,true);
        $criteria->compare('type',$this->type,true);
        $criteria->compare('tag',$this->tag,true);
        $criteria->compare('creator',$this->creator,true);
        $criteria->compare('theme',$this->theme,true);
        $criteria->compare('config',$this->config,true);
        $criteria->compare('description',$this->description,true);
        $criteria->compare('friend_links',$this->friend_links,true);
        $criteria->compare('url',$this->url,true);
        $criteria->compare('member_num',$this->member_num,true);
        $criteria->compare('post_num',$this->post_num,true);
        $criteria->compare('create_time',$this->create_time,true);
        $criteria->compare('last_modify_time',$this->last_modify_time,true);
        $criteria->compare('status',$this->status,true);

        return new CActiveDataProvider(get_class($this), array(
            'criteria'=>$criteria,
        ));
    }
}
